import request from '@/utils/request'

// 创建订单
export function createOrder(data) {
  return request({
    url: '/payment/order',
    method: 'post',
    data
  })
}

// 支付订单（模拟）
export function payOrder(orderNo, payMethod) {
  return request({
    url: '/payment/pay',
    method: 'post',
    params: { orderNo, payMethod }
  })
}

// 取消订单
export function cancelOrder(orderNo) {
  return request({
    url: '/payment/cancel',
    method: 'post',
    params: { orderNo }
  })
}

// 查询历史订单（根据角色权限）
export function getUserOrders(userId, year, category, userRole) {
  return request({
    url: '/payment/history',
    method: 'get',
    params: { userId, year, category, userRole }
  })
}

// 管理员查询所有订单
export function getAllOrders(year, category, username) {
  return request({
    url: '/payment/admin/orders',
    method: 'get',
    params: { year, category, username }
  })
}

// 查询订单详情
export function getOrderByOrderNo(orderNo) {
  return request({
    url: `/payment/order/${orderNo}`,
    method: 'get'
  })
}

// 查询校园卡余额
export function getCardBalance(userId) {
  return request({
    url: '/payment/card/balance',
    method: 'get',
    params: { userId }
  })
}

// 校园卡充值
export function rechargeCard(userId, amount) {
  return request({
    url: '/payment/card/recharge',
    method: 'post',
    params: { userId, amount }
  })
}

// 获取学生专业费用信息
export function getStudentFees(userId) {
  return request({
    url: '/payment/student/fees',
    method: 'get',
    params: { userId }
  })
}

// 验证学生专业信息
export function validateStudentMajor(userId) {
  return request({
    url: '/payment/student/validate',
    method: 'get',
    params: { userId }
  })
} 